﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using BiffenService.Model;

namespace BiffenService.Db
{
    class TheaterDb
    {

        public Theater FindById(int theaterId)
        {
            string sql = "SELECT * FROM bif_theater WHERE Id = @id";
            SqlCommand comm = DbClient.GetDbCommand(sql);

            comm.Parameters.AddWithValue("@id", theaterId);

            IDataReader reader = comm.ExecuteReader();
            Theater theater = null;
            if(reader.Read()) {
                theater = new Theater((int)reader["Id"]);
                theater.NoCols = (int)reader["NoCols"];
                theater.NoRows = (int)reader["NoRows"];
            }

            reader.Close();

            return theater;
        }

    }
}
